package com.sw.small_world.fragment.home.topicsquare;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sw.small_world.R;
import com.sw.small_world.activity.ClickButtonActivity;
import com.sw.small_world.adapter.topicsquare.EducationExAdapter;
import com.sw.small_world.adapter.topicsquare.JobExAdapter;
import com.sw.small_world.fragment.base.BaseFragment;
import com.sw.small_world.utils.ConstantUtils;
import com.sw.small_world.utils.PopUtils;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/3/21.
 */

public class PersonInfoFragment extends BaseFragment {


    @Bind(R.id.person_info_portrait)
    ImageView personInfoPortrait;
    @Bind(R.id.person_info_name)
    TextView personInfoName;
    @Bind(R.id.person_info_field)
    TextView personInfoField;
    @Bind(R.id.person_info_position)
    TextView personInfoPosition;
    @Bind(R.id.person_info_company)
    TextView personInfoCompany;
    @Bind(R.id.person_info_connection_value_no)
    TextView person_info_connection_value_no;
    @Bind(R.id.person_info_address)
    TextView personInfoAddress;
    @Bind(R.id.person_info_connection_value)
    TextView personInfoConnectionValue;
    @Bind(R.id.person_info_connection_num)
    TextView personInfoConnectionNum;
    @Bind(R.id.list_view_job_experience)
    ListView listViewJobExperience;
    @Bind(R.id.list_view_education_experience)
    ListView listViewEducationExperience;
    @Bind(R.id.friend1)
    LinearLayout friend1;
    @Bind(R.id.grade_person_info)
    RelativeLayout gradePersonInfo;
    @Bind(R.id.sendMessage)
    RelativeLayout sendMessage;
    @Bind(R.id.friend2)
    LinearLayout friend2;
    @Bind(R.id.person_info_portrait_no)
    ImageView personInfoPortraitNo;
    @Bind(R.id.person_info_name_no)
    TextView personInfoNameNo;
    @Bind(R.id.person_info_address_no)
    TextView personInfoAddressNo;
    @Bind(R.id.person_info_tele)
    TextView personInfoTele;
    @Bind(R.id.rl)
    RelativeLayout rl;
    @Bind(R.id.add_friend)
    TextView addFriend;
    @Bind(R.id.not_friend)
    RelativeLayout notFriend;
    private ClickButtonActivity activity;
    private ArrayList<String> jobExList = new ArrayList<>();
    private ArrayList<String> eductionExList = new ArrayList<>();
    private ArrayList<String> group = new ArrayList<>();
    private JobExAdapter jobExAdapter;
    private EducationExAdapter educationExAdapter;
    private View view;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        activity = (ClickButtonActivity) getActivity();
        setActionBar();
    }

    @Override
    protected Object requestData() {
        for (int i = 0; i < 2; i++) {
            jobExList.add("" + i);
            eductionExList.add("" + i);
        }
        return ConstantUtils.STATE_SUCCESSED;
    }

    @Override
    protected View getSuccessView() {
        view = View.inflate(activity, R.layout.fragment_person_info, null);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
        if (false) {
            friend1.setVisibility(View.VISIBLE);
            friend2.setVisibility(View.VISIBLE);
            notFriend.setVisibility(View.GONE);
            activity.ivRight.setVisibility(View.VISIBLE);
            jobExAdapter = new JobExAdapter(jobExList, activity);
            educationExAdapter = new EducationExAdapter(eductionExList, activity);
            listViewJobExperience.setAdapter(jobExAdapter);
            listViewEducationExperience.setAdapter(educationExAdapter);
        } else {
            friend1.setVisibility(View.GONE);
            friend2.setVisibility(View.GONE);
            notFriend.setVisibility(View.VISIBLE);
            activity.ivRight.setVisibility(View.GONE);
        }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {

        }
    }

    private void setActionBar() {
        activity.tvTitle.setText("王康的资料");
        activity.ivRight.setVisibility(View.VISIBLE);
        activity.ivRight.setImageResource(R.drawable.haoyouziliao_gengduo);
        group.add("屏蔽");
        group.add("举报");
        group.add("删除好友");
        activity.ivRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new PopUtils().initMoreListPop(group, new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    }
                }).showAsDropDown(activity.ivRight);
            }
        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
